<!--
 * @Author: QinJiu
 * @Date: 2022-07-20 09:09:50
 * @LastEditors: Qinjiu
 * @LastEditTime: 2022-07-22 14:22:10
 * @Description:
-->
<template>
  <div class="about">
    <h1>This is an about page</h1>
    {{ count }}
    <div style="width: 300px; height: 300px">
      <Test />
    </div>

    <el-button @click="logout">退出登录</el-button>
  </div>
</template>

<script>
import to from "@/utils/await-to.js";
import { showDesktopNotify } from "@/utils/desktop-notify";
import { getAsyncComponent } from "@/utils/commonFunc.js";

export default {
  components: {
    Test: getAsyncComponent(() => import("@/components/Test.vue")),
  },
  data() {
    return {
      count: 1,
    };
  },
  methods: {
    async logout() {
      const [error, result] = await to(this.$store.dispatch("user/logout"));
      if (error) {
        showDesktopNotify("登出", { body: error });
      } else {
        // 一顿判断 -> 此处模拟成功
        // ......
        showDesktopNotify("登出", { body: "成功！" });
        this.$router.push(`/login?redirect=${this.$route.fullPath}`);
      }
    },
  },
};
</script>
